//
//  TempLineViewController.m
//  Sky
//
//  Created by chenheren on 16/8/30.
//  Copyright © 2016年 chen. All rights reserved.
//

#import "TempLineViewController.h"
#import "HRCurveLineView.h"

@interface TempLineViewController ()

@property (strong, nonatomic) HRCurveLineView *curveLineView;

@end

@implementation TempLineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:0.953 green:1.000 blue:0.748 alpha:1.000];

     self.curveLineView = [[HRCurveLineView alloc]initWithFrame:CGRectMake(0, 70, self.view.frame.size.width, 200)];
    [self.curveLineView setuWithXArray:self.XArray andYArray:self.YArrayLow];
    [self.view addSubview:self.curveLineView];
    
    //添加返回按键
    UIButton *goBackBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    goBackBtn.frame = CGRectMake(10, 20, 40, 30);
    [goBackBtn setTitle:@"< 返回" forState:UIControlStateNormal];
    goBackBtn.font = [UIFont systemFontOfSize:12];
    [goBackBtn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [goBackBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:goBackBtn];
    
    UISegmentedControl *segmentControl = [[UISegmentedControl alloc]initWithItems:@[@"最低",@"最高"]];
    segmentControl.frame =CGRectMake(self.view.frame.size.width/2-50, 350, 100, 30);
    [segmentControl addTarget:self action:@selector(segmentSelect:) forControlEvents:UIControlEventValueChanged];
    [segmentControl setSelectedSegmentIndex:0];
    [self.view addSubview:segmentControl];
}

-(void)goBack{
    [self dismissViewControllerAnimated:NO completion:nil];
}

-(void)segmentSelect:(UISegmentedControl *)segmentControl{
    
    NSUInteger index = segmentControl.selectedSegmentIndex;
    if (index == 0) {
        [self.curveLineView setuWithXArray:self.XArray andYArray:self.YArrayLow];
    }else{
        [self.curveLineView setuWithXArray:self.XArray andYArray:self.YArrayHigh];
    }
    
    
}


@end
